<template>
<transition
  name="fade"
  enter-active-class="fadeInDown"
  leave-active-class="fadeOutUp"
>
  <div id="accounts" v-show="accountsShow" :accountsShow="accountsShow">
    <input type="password" name v-model="form.oldpassword" placeholder="旧密码" class="my-input"   />
    <input type="password" name v-model="form.newpassword" placeholder="新密码" class="my-input"  />
    <input type="password" name v-model="form.newpassword2" placeholder="再次确认密码" class="my-input" />
      <mu-button class="btn" @click="save">保存</mu-button>
  </div>
</transition>
</template>

<script>
import { Toast } from "vant";
import "vant/lib/toast/style/index";
export default {
  data() {
    return {
        accountsShow:false,
      form: {
        oldpassword: "",
        newpassword: "",
        newpassword2: ""
      }
    };
  },
   methods: {
    Showaccountsdiv() {
      this.accountsShow = true;
    },
    save(){
      if(this.form.oldpassword==''){

        Toast('请输入旧密码');
        return;
      }
       if(this.form.newpassword==''){

        Toast('请输入新密码');
        return;
      }
       if(this.form.newpassword2==''){

        Toast('请再次输入新密码');
        return;
      }
      if(this.form.newpassword2!=this.form.newpassword){
        Toast('两次输入的密码不一致');
        return;
      }
      this.$api.changePwd(this.form.newpassword2,this.form.oldpassword).then(res=>{
        console.log(res)
        Toast('修改密码成功');
       this.accountsShow = false;
      })


    }
   }
};
</script>

<style>
</style>
